<extend name="Public/base" />

<block name="content">
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a href="{:U('Index/index')}" title="首页" class="tip-bottom"><i
				class="icon-home"></i> 首页</a> <a href="{:U('Auth/index')}" class="tip-bottom">权限管理</a><a href="javascript:void(0);" class="current">{$meta_title}</a>
		</div>
	</div>
	<div class="container-fluid">
		<br>
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-title">
		        		<ul class="nav nav-tabs">
		        			<li style="width:100px; text-align:center;"><a href="{:U('auth',array('group_id'=>I('group_id')))}">访问授权</a></li>
		        			<li class="active" style="width:100px; text-align:center;"><a href="javascript:void(0);">{$meta_title}</a></li>
							<li  style="width:100px; text-align:center;"><a href="{:U('user',array('group_id'=>I('group_id')))}">成员授权</a></li>
		            	</ul>
		          	</div>
					<div class="widget-content ">
						<form class="save-category" action="{:U('category')}">
				            <input type="hidden" name="group_id" value="{:I('group_id')}">
				            <div class="category auth-category">
				                <div class="hd cf">
				                    <div class="fold">折叠</div>
				                    <div class="order">选择</div>
				                    <div class="name">栏目名称</div>
				                </div>
				                {:R('Auth/tree', array($group_list))}
				            </div>
				
				            <div class="tb-unit-bar">
				                <button class="btn submit-btn ajax-post" type="submit"url="{:U('category')}" target-form="save-category">确 定</button>
				                <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
				            </div>
				        </form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
+function($){
    /* 分类展开收起 */
	$(".category dd").prev().find(".fold i").addClass("icons-unfold")
		.click(function(){
			var self = $(this);
			if(self.hasClass("icons-unfold")){
				self.closest("dt").next().slideUp("fast", function(){
					self.removeClass("icons-unfold").addClass("icons-fold");
				});
			} else {
				self.closest("dt").next().slideDown("fast", function(){
					self.removeClass("icons-fold").addClass("icons-unfold");
				});
			}
		});
    var auth_groups = [{$authed_group}];
    $('.cate_id').each(function(){
        if( $.inArray( parseInt(this.value,10),auth_groups )>-1 ){
        	$(this).parent("span").addClass('checked');
            $(this).prop('checked',true);
        }
    });
    //点击复选框  临时写   有优化空间$$$$$$
    $(".cate_id").on("change", function () {
    	var thisObj = $(this);
    	if(this.checked){
    		thisObj.closest(".cate-item").find(".checker span").addClass("checked").find("input").attr("checked","checked");
       	}else{
       		thisObj.closest(".cate-item").find(".checker span").removeClass("checked").find("input").removeAttr("checked");
       	}
    	var level_1 = $(this).closest(".up_level_1");
    	var level_2 = $(this).closest(".up_level_2");
    	var firstLength = level_1.find(".checker").length-2;
    	var secondLength = level_2.find(".checker").length-2;
    	
    	var i = 0 ;
    	//当前为二级菜单
    	if(level_2.find("dd input").length!=0){
    		level_2.find("dd input").each(function(){
        		if(this.checked){
        			level_2.find("dt:first .checker span").addClass("checked").find("input").attr("checked","checked");
        			return false;
        		}else{
        			if(i==secondLength){
        				level_2.find("dt:first .checker span").removeClass("checked").find("input").removeAttr("checked");
        			}
        		}
        		i++;
        	});
    	}
    	//当前为一级菜单
    	i=0;
    	level_1.find("dd input").each(function(){
    		if(this.checked){
    			level_1.find("dt:first .checker span").addClass("checked").find("input").attr("checked","checked");
    			return false;
    		}else{
    			if(i==firstLength){
    				level_1.find("dt:first .checker span").removeClass("checked").find("input").removeAttr("checked");
    			}
    		}
    		i++;
    	});
    	
   		
		
    }); 
   

}(jQuery);
//导航高亮
highlight_subnav("{:U('Auth/index')}");
</script>
</block>
